package com.sl.service;

import com.sl.mapper.CheckDocumentMapper;
import com.sl.pojo.CheckDocument;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CheckDocumentService {

    @Resource
    private CheckDocumentMapper checkDocumentMapper;


    //查询：主键
    public CheckDocument findCDById(Integer id){
        return  checkDocumentMapper.selectByPrimaryKey(id);
    }
    //查询：所有
    public List<CheckDocument> findAllPosition(){
        return  checkDocumentMapper.selectAll();
    }

    //增加
    public void addCD(CheckDocument checkDocument){
        checkDocumentMapper.insertSelective(checkDocument);
    }
    //修改
    public void updateCD(CheckDocument checkDocument){
        checkDocumentMapper.updateByPrimaryKeySelective(checkDocument);
    }

    public void deleteCD(CheckDocument checkDocument) {
        checkDocumentMapper.deleteByPrimaryKey(checkDocument);
    }
    public List<CheckDocument> findCDByCheckUuid(String uuid){
        Example example = new Example(CheckDocument.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("checkUuid",uuid);
     return    checkDocumentMapper.selectByExample(example);
    }
    public void deleteCDByCheckUuid(String uuid){
        Example example = new Example(CheckDocument.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("checkUuid",uuid);
        checkDocumentMapper.deleteByExample(example);}
}
